import UserAPI from '@/api/user'
import type { UserQuery } from '@/api/user/model'
import type { IContentConfig } from '@/components/PageContent/index.vue'

const contentConfig: IContentConfig<UserQuery> = {
  pageName: 'sys:user',
  table: {
    highlightCurrentRow: true,
    fit: true,
  },
  indexAction(params) {
    if ('createAt' in params) {
      const createAt = params.createAt as string[]
      params.startTime = createAt[0]
      params.endTime = createAt[1]
      delete params.createAt
    }
    return UserAPI.getPage(params)
  },
  pk: 'id',
  toolbar: [
    'add',
  ],
  cols: [
    { label: '课程主图', align: 'center', prop: 'avatar', templet: 'image' },
    { label: '课程信息', align: 'center', prop: 'nickname', width: 120 },
    { label: '课程讲师', align: 'center', prop: 'mobile', width: 100 },
    { label: '课班信息', align: 'center', prop: 'mobile', width: 120 },
    { label: '开课时间', align: 'center', prop: 'mobile', width: 120 },
    { label: '提交时间', align: 'center', prop: 'mobile', width: 180 },
    { label: '课时费/结算对象', align: 'center', prop: 'mobile', width: 180 },
    {
      label: '上架状态',
      align: 'center',
      prop: 'status',
      templet: 'custom',
      slotName: 'status',
    },
    {
      label: '操作',
      fixed: 'right',
      width: 140,
      templet: 'tool',
      operat: [
        {
          name: 'reset_pwd',
          auth: 'password:reset',
          icon: 'refresh-left',
          text: '下架',
        },
        'edit',
      ],
    },
  ],
}

export default contentConfig
